<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div>
        <h1>今天在上课</h1>
        <h1>明天也上课</h1>
        <h1>后天不上课</h1>
    </div>
    <script src="/jquery.js"></script>
    <script>
        //第一个子元素
        $('div :first-child').css('background','#f00');

        //最后一个子元素
        $('div :last-child').css('background','#e0f');

        //第N个子元素
        $('div :nth-child(2n)').css('background','#0a0');
    </script>
</body>
</html>